package site.yunnong.atvris.portal.controller;

import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import site.yunnong.atvris.common.api.ResultVO;
import site.yunnong.atvris.common.dto.UserInterestTagBatchParam;
import site.yunnong.atvris.common.dto.UserInterestTagParam;
import site.yunnong.atvris.service.UserInterestTagService;

import javax.annotation.Resource;


/**
 * 一个user只能有5个兴趣标签
 *
 * @author zhangjinghao
 * @email jhzhang9102@163.com
 * @date 2021-07-09 23:45:37
 */
@Slf4j
@RestController
@RequestMapping("/user-interest-tag")
public class UserInterestTagController {
    
    @Resource
    private UserInterestTagService userInterestTagService;

    @ApiOperation("保存用户添加的兴趣标签")
    @PostMapping("/save")
    public ResultVO save(@RequestBody UserInterestTagBatchParam param) {
        log.info("UserInterestTagController.save param: {}", param);
        userInterestTagService.save(param);
        log.info("UserInterestTagController.save params: {} 执行成功", param);
        return new ResultVO<>().success();
    }
    
    @ApiOperation("插入新的兴趣标签")
    @PostMapping("/insert")
    public ResultVO insert(@RequestBody UserInterestTagParam param) {
        userInterestTagService.insert(param);
        return new ResultVO().success();
    }
    
    @ApiOperation("删除兴趣标签")
    @PostMapping("/delete")
    public ResultVO delete(@RequestParam("tid") Long tid) {
        userInterestTagService.deleteByTid(tid);
        return new ResultVO().success();
    }
}
